package com.servlet;

import com.dao.imp.AddUpdDelDaoImp;
import net.sf.json.JSONObject;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/12/1 17:31
 **/

@WebServlet(name = "SendGoodServlet", value = "/SendGoodServlet")
public class SendGoodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String order_id = request.getParameter("orderNo");

        String sql = "UPDATE orders  SET status = 1 WHERE order_id = "+order_id;

        AddUpdDelDaoImp addUpdDelDaoImp = new AddUpdDelDaoImp();
        boolean result = addUpdDelDaoImp.addUpdDelGoods(sql);
        String msg="";
        if (result==false){
            msg = "更新失败";
        }else {
            msg = "更新成功";
        }

        JSONObject json = JSONObject.fromObject("{msg:\""+msg+"\"}");

        response.getWriter().print(json);
    }
}
